<?php

/**
 * This is the model class for table "dok_terima".
 *
 * The followings are the available columns in table 'dok_terima':
 * @property integer $no_reg
 * @property string $no_bayar
 * @property string $no_form
 * @property string $kode_jns
 * @property string $tahun
 * @property string $sts_prs
 * @property string $sts_byr
 * @property string $sts_nhl
 * @property string $no_op
 * @property string $kode_jsd
 * @property string $kode_ppat
 * @property string $nik
 * @property string $nama_wp
 * @property string $alamat_wp
 * @property string $kec_wp
 * @property string $kel_wp
 * @property string $rt_wp
 * @property string $rw_wp
 * @property string $kota_wp
 * @property string $kode_poswp
 * @property string $tgl_masuk
 * @property string $tgl_selesai
 * @property string $ket
 * @property string $tgl_val
 * @property string $no_val
 * @property string $noreg_njop
 * @property string $kode_user
 *
 * The followings are the available model relations:
 * @property Pemohon[] $pemohons
 * @property Users $kodeUser
 * @property ObjekPajak $noOp
 * @property JenisPrh $kodeJns
 * @property JenisDok $kodeJsd
 * @property Ppat $kodePpat
 * @property Sptpd[] $sptpds
 */
class DokTerima extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'dok_terima';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('kode_user', 'required'),
			array('no_reg', 'numerical', 'integerOnly'=>true),
			array('no_bayar', 'length', 'max'=>11),
			array('no_form', 'length', 'max'=>20),
			array('kode_jns, kode_jsd', 'length', 'max'=>2),
			array('tahun', 'length', 'max'=>4),
			array('sts_prs, sts_byr, sts_nhl', 'length', 'max'=>1),
			array('no_op', 'length', 'max'=>18),
			array('kode_ppat', 'length', 'max'=>17),
			array('nik', 'length', 'max'=>16),
			array('nama_wp, alamat_wp, kec_wp, kel_wp, noreg_njop', 'length', 'max'=>50),
			array('rt_wp, rw_wp', 'length', 'max'=>3),
			array('kota_wp', 'length', 'max'=>15),
			array('kode_poswp', 'length', 'max'=>7),
			array('ket', 'length', 'max'=>255),
			array('no_val', 'length', 'max'=>5),
			array('kode_user', 'length', 'max'=>8),
			array('tgl_masuk, tgl_selesai, tgl_val', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('no_reg, no_bayar, no_form, kode_jns, tahun, sts_prs, sts_byr, sts_nhl, no_op, kode_jsd, kode_ppat, nik, nama_wp, alamat_wp, kec_wp, kel_wp, rt_wp, rw_wp, kota_wp, kode_poswp, tgl_masuk, tgl_selesai, ket, tgl_val, no_val, noreg_njop, kode_user', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'pemohons' => array(self::HAS_MANY, 'Pemohon', 'no_reg'),
			'kodeUser' => array(self::BELONGS_TO, 'Users', 'kode_user'),
			'noOp' => array(self::BELONGS_TO, 'ObjekPajak', 'no_op'),
			'kodeJns' => array(self::BELONGS_TO, 'JenisPrh', 'kode_jns'),
			'kodeJsd' => array(self::BELONGS_TO, 'JenisDok', 'kode_jsd'),
			'kodePpat' => array(self::BELONGS_TO, 'Ppat', 'kode_ppat'),
			'sptpds' => array(self::HAS_MANY, 'Sptpd', 'no_reg'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'no_reg' => 'No Reg',
			'no_bayar' => 'No Bayar',
			'no_form' => 'No Form',
			'kode_jns' => 'Kode Jns',
			'tahun' => 'Tahun',
			'sts_prs' => 'Sts Prs',
			'sts_byr' => 'Sts Byr',
			'sts_nhl' => 'Sts Nhl',
			'no_op' => 'No Op',
			'kode_jsd' => 'Kode Jsd',
			'kode_ppat' => 'Kode Ppat',
			'nik' => 'Nik',
			'nama_wp' => 'Nama Wp',
			'alamat_wp' => 'Alamat Wp',
			'kec_wp' => 'Kec Wp',
			'kel_wp' => 'Kel Wp',
			'rt_wp' => 'Rt Wp',
			'rw_wp' => 'Rw Wp',
			'kota_wp' => 'Kota Wp',
			'kode_poswp' => 'Kode Poswp',
			'tgl_masuk' => 'Tgl Masuk',
			'tgl_selesai' => 'Tgl Selesai',
			'ket' => 'Ket',
			'tgl_val' => 'Tgl Val',
			'no_val' => 'No Val',
			'noreg_njop' => 'Noreg Njop',
			'kode_user' => 'Kode User',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('no_reg',$this->no_reg);
		$criteria->compare('no_bayar',$this->no_bayar,true);
		$criteria->compare('no_form',$this->no_form,true);
		$criteria->compare('kode_jns',$this->kode_jns,true);
		$criteria->compare('tahun',$this->tahun,true);
		$criteria->compare('sts_prs',$this->sts_prs,true);
		$criteria->compare('sts_byr',$this->sts_byr,true);
		$criteria->compare('sts_nhl',$this->sts_nhl,true);
		$criteria->compare('no_op',$this->no_op,true);
		$criteria->compare('kode_jsd',$this->kode_jsd,true);
		$criteria->compare('kode_ppat',$this->kode_ppat,true);
		$criteria->compare('nik',$this->nik,true);
		$criteria->compare('nama_wp',$this->nama_wp,true);
		$criteria->compare('alamat_wp',$this->alamat_wp,true);
		$criteria->compare('kec_wp',$this->kec_wp,true);
		$criteria->compare('kel_wp',$this->kel_wp,true);
		$criteria->compare('rt_wp',$this->rt_wp,true);
		$criteria->compare('rw_wp',$this->rw_wp,true);
		$criteria->compare('kota_wp',$this->kota_wp,true);
		$criteria->compare('kode_poswp',$this->kode_poswp,true);
		$criteria->compare('tgl_masuk',$this->tgl_masuk,true);
		$criteria->compare('tgl_selesai',$this->tgl_selesai,true);
		$criteria->compare('ket',$this->ket,true);
		$criteria->compare('tgl_val',$this->tgl_val,true);
		$criteria->compare('no_val',$this->no_val,true);
		$criteria->compare('noreg_njop',$this->noreg_njop,true);
		$criteria->compare('kode_user',$this->kode_user,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return DokTerima the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
